package algorithm.union;

import algorithm.tools.Times;

/**
 * @author cyt
 * @create 2020-09-05 16:06
 */
public class UnionTest implements Cloneable {

    private String name;

    public static void main(String[] args) throws CloneNotSupportedException {
        UnionFind find = new UnionQu(12);
        find.union(6, 7);
        find.union(8, 9);
        find.union(9, 11);
        find.union(9, 10);

        find.union(0, 1);
        find.union(0, 4);
        find.union(0, 3);
        find.union(3, 2);
        find.union(2, 5);

        System.out.println(find.isSame(2, 4));
        UnionTest test = new UnionTest();
        test.name = "cyt";
        UnionTest clone = (UnionTest) test.clone();

        System.out.println(test.name.hashCode());
        System.out.println(clone.name.hashCode());
        int count = 900000;
//        clone.abstractclass.test(new UnionQu(count), count);
//        abstractclass.test.abstractclass.test(new UnionQf(count), count);
//        abstractclass.test.abstractclass.test(new UnionQuPrime(count), count);
    }

    public void test(UnionFind find, int count) {
        Times.test(find.getClass().getSimpleName(), () -> {
            for (int i = 0; i < count; i++) {
                find.union((int) Math.random() * count
                        , (int) Math.random() * count);
            }

            for (int i = 0; i < count; i++) {
                find.isSame((int) Math.random() * count
                        , (int) Math.random() * count);
            }
        });
    }
}
